﻿#ifndef ORDERPAGE_H
#define ORDERPAGE_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QMessageBox>
#include <QDebug>
#include "header.h"
#include "database.h"

class OrderPage : public QWidget
{
    Q_OBJECT

public:
    explicit OrderPage(database &db, QWidget *parent = nullptr);
    ~OrderPage();

    // 设置用户信息
    void setUserInfo(int phoneId, int userIdentity);

    // 加载可用订单
    void loadAvailableOrders();
    void loadAcceptedOrders();

    void  setUserPhoneId(int phoneId){
        this->userPhoneId = phoneId;
    }
    void  setuserIdentity(int userIdentity){
        this->userIdentity = userIdentity;
    }

private slots:
    // 处理接单按钮点击
    void onAcceptOrderClicked();
    void onDeliveredClicked();

private:
    database &db;
    QLabel *titleLabel;
    QTableWidget *ordersTable;
    QTableWidget *acceptedOrdersTable;
    QPushButton *refreshButton;
    int userPhoneId;
    int userIdentity;

    // 创建UI组件
    void setupUI();
    // 创建接单按钮
    QPushButton* createAcceptButton(int row);
};

#endif // ORDERPAGE_H
